<?

$value = $value ? $value : time();
$value = is_numeric($value) ? $value : strtotime($value);

$second = date("s",$value);
$minute = date("i",$value);
$hour = date("H",$value);
$day = date("d",$value);
$month = date("n",$value);
$year = date("Y",$value);


?>
<tr>
	<td width="130"><?= $title; ?>:</td>
	<td>
		<? if($date): ?>
		<select name="<?= $name; ?>_month">
			<? foreach(array("January","Febuary","March","April","May","June","July","August","September","October","November","December") as $key=>$monthName): ?>
			<option value="<?=$key+1;?>" <? if($month == $key+1): ?> selected=true<? endif;?>><?=$monthName;?></option>
			<? endforeach; ?>
		</select>
		<select name="<?= $name; ?>_day">
			<? for($i=1; $i<=31; $i++): ?>
			<option value="<?=$i;?>" <? if($day == $i): ?> selected=true<? endif;?>><?=$i;?></option>
			<? endfor; ?>
		</select>
		<select name="<?= $name; ?>_year">
			<? $curYear=date("Y"); for($i=$curYear; $i<=$curYear+5; $i++): ?>
			<option value="<?=$i;?>" <? if($year == $i): ?> selected=true<? endif;?>><?=$i;?></option>
			<? endfor; ?>
		</select>
		<input type="hidden" name="<?=$name;?>" value="<?=$value;?>"/> 
		<? endif; ?>
		<? if($time && $date):?>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;		
		<? endif; ?>
		<? if($time): ?>
		<select name="<?= $name; ?>_hour">
			<? for($i=0; $i<24; $i++): ?>
				<option value="<?=$i;?>" <? if($hour == $i): ?> selected=true<? endif;?>><?= date("g",mktime($i)); ?></option>
			<? endfor; ?>
		</select>
		<select name="<?= $name; ?>_minute">
			<? for($i=1; $i<=60; $i++): ?>
			<option value="<?=$i;?>" <? if($minute == $i): ?> selected=true<? endif;?>><?=$i;?></option>
			<? endfor; ?>
		</select>
		<select name="<?= $name; ?>_second">
			<? for($i=1; $i<=60; $i++): ?>
			<option value="<?=$i;?>" <? if($second == $i): ?> selected=true<? endif;?>><?=$i;?></option>
			<? endfor; ?>
		</select>
		<input type="hidden" name="<?=$name;?>" value="<?=$value;?>"/> 
		<? endif; ?>
	</td>
</tr>

<? if($error): ?>
	<tr>
		<td></td>
		<td><img src='/img/silk/exclamation.png' style="vertical-align:top">&nbsp;&nbsp;<span style='color:Black; font-weight:600; font-size:12px; font-family:Helvetica'><?= $error; ?></span></td>
	</tr>
<? endif; ?>